<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>父子调用</title>
    </head>
    <body>
        <div id="app">
           <cpn1 ref="aaa"></cpn1>
           <button @click="btnClick">点依稀</button></button>
        </div>
        <template id="cpntem">
            <div>
              <h2>子组件
              </h2></h2>
            </div>
        </template>
        <script src="../vue.js"></script>
        <script>
            const app = new Vue({
                el:'#app',
                data:{
                  message:'hello'
                },
                methods:{
                    btnClick(){
                        //1 $children
                            // console.log(this.$children[0].zzz)
                            // this.$children[0].showMessage()
                        // 2 $ref
                        this.$refs.aaa.showMessage()
                    }
                },
                components:{
                    cpn1:{
                        template:'#cpntem',
                        methods:{
                            showMessage(){
                                console.log("showmessageaaaa")
                                console.log(this.$root.message)
                               
                            }
                        },
                        data(){
                            return{
                                zzz:'得到zzz了'
                            }
                        }
                    }
                        
                }
            })
        </script>
        
    </body>
</html>